import { useNavigate ,Router, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import About from './pages/About';
import Xhdd from './pages/xiaoshou';
import Xhck from './pages/xhchu';
import React, { useState } from 'react';
import {
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  UploadOutlined,
  UserOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons';
import { Button, Layout, Menu, theme } from 'antd';

const { Header, Sider, Content } = Layout;

const App: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const navigate = useNavigate();

  return (
    <Layout>
      <Sider trigger={null} collapsible collapsed={collapsed}>
        <div className="demo-logo-vertical" />
        <Menu
          theme="dark"
          mode="inline"
          defaultSelectedKeys={['/']}
          items={[
            {
              key: '/1',
              icon: <UserOutlined />,
              label: '客户管理',
              children: [
                {
                  key: '/home',
                  icon: <VideoCameraOutlined />,
                  label: '客户列表',
                },
                {
                  key: '/about',
                  icon: <UploadOutlined />,
                  label: '跟进记录',
                }
              ]
            },
            {
              key: '/2',
              icon: <UserOutlined />,
              label: '销售管理',
              children: [
                {
                  key: '/xhdd',
                  icon: <VideoCameraOutlined />,
                  label: '销售订单',
                },
                {
                  key: '/xhck',
                  icon: <UploadOutlined />,
                  label: '销售出库',
                }
              ]
            }
          ]}
          onClick={(e) => {
            navigate(e.key)
          }
          }
        />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }}>
          <Button
            type="text"
            icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
            onClick={() => setCollapsed(!collapsed)}
            style={{
              fontSize: '16px',
              width: 64,
              height: 64,
            }}
          />
        </Header>
        <Content
          style={{
            margin: '24px 16px',
            padding: 24,
            background: colorBgContainer,
            borderRadius: borderRadiusLG,
          }}
        >
          <Routes>
            <Route path="/home" element={<Home />} />
            <Route path="/about" element={<About />} />
            <Route path="/xhdd" element={<Xhdd />} />
            <Route path="/xhck" element={<Xhck />} />
          </Routes>
        </Content>
      </Layout>
    </Layout>
  );
};

export default App;
